/**
 */
package de.thwildau.tm.moses.avro.avdl.impl;

import de.thwildau.tm.moses.avro.avdl.AliasAnnotation;
import de.thwildau.tm.moses.avro.avdl.Annotation;
import de.thwildau.tm.moses.avro.avdl.Argument;
import de.thwildau.tm.moses.avro.avdl.ArrayType;
import de.thwildau.tm.moses.avro.avdl.AvdlFactory;
import de.thwildau.tm.moses.avro.avdl.AvdlPackage;
import de.thwildau.tm.moses.avro.avdl.AvroIdl;
import de.thwildau.tm.moses.avro.avdl.BOOL;
import de.thwildau.tm.moses.avro.avdl.BaseType;
import de.thwildau.tm.moses.avro.avdl.BaseTypeRef;
import de.thwildau.tm.moses.avro.avdl.BooleanRef;
import de.thwildau.tm.moses.avro.avdl.ComplexTypeRef;
import de.thwildau.tm.moses.avro.avdl.ConstValue;
import de.thwildau.tm.moses.avro.avdl.DefType;
import de.thwildau.tm.moses.avro.avdl.Definitions;
import de.thwildau.tm.moses.avro.avdl.DoubleRef;
import de.thwildau.tm.moses.avro.avdl.EnumFields;
import de.thwildau.tm.moses.avro.avdl.Field;
import de.thwildau.tm.moses.avro.avdl.FieldType;
import de.thwildau.tm.moses.avro.avdl.FixedLengthField;
import de.thwildau.tm.moses.avro.avdl.HexRef;
import de.thwildau.tm.moses.avro.avdl.ImportTypeRef;
import de.thwildau.tm.moses.avro.avdl.Imports;
import de.thwildau.tm.moses.avro.avdl.IntRef;
import de.thwildau.tm.moses.avro.avdl.JavaclassAnnotation;
import de.thwildau.tm.moses.avro.avdl.MapType;
import de.thwildau.tm.moses.avro.avdl.Name;
import de.thwildau.tm.moses.avro.avdl.NamespaceAnnotation;
import de.thwildau.tm.moses.avro.avdl.NumberRef;
import de.thwildau.tm.moses.avro.avdl.OrderAnnotation;
import de.thwildau.tm.moses.avro.avdl.Protocol;
import de.thwildau.tm.moses.avro.avdl.RPCMessage;
import de.thwildau.tm.moses.avro.avdl.Record;
import de.thwildau.tm.moses.avro.avdl.ReturnType;
import de.thwildau.tm.moses.avro.avdl.StringRef;
import de.thwildau.tm.moses.avro.avdl.Throws;
import de.thwildau.tm.moses.avro.avdl.UnionFieldType;
import de.thwildau.tm.moses.avro.avdl.UnionType;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class AvdlFactoryImpl extends EFactoryImpl implements AvdlFactory
{
  /**
   * Creates the default factory implementation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public static AvdlFactory init()
  {
    try
    {
      AvdlFactory theAvdlFactory = (AvdlFactory)EPackage.Registry.INSTANCE.getEFactory(AvdlPackage.eNS_URI);
      if (theAvdlFactory != null)
      {
        return theAvdlFactory;
      }
    }
    catch (Exception exception)
    {
      EcorePlugin.INSTANCE.log(exception);
    }
    return new AvdlFactoryImpl();
  }

  /**
   * Creates an instance of the factory.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AvdlFactoryImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case AvdlPackage.AVRO_IDL: return createAvroIdl();
      case AvdlPackage.PROTOCOL: return createProtocol();
      case AvdlPackage.DEFINITIONS: return createDefinitions();
      case AvdlPackage.ERROR: return createError();
      case AvdlPackage.RECORD: return createRecord();
      case AvdlPackage.FIELD: return createField();
      case AvdlPackage.ENUM: return createEnum();
      case AvdlPackage.ENUM_FIELDS: return createEnumFields();
      case AvdlPackage.FIXED_LENGTH_FIELD: return createFixedLengthField();
      case AvdlPackage.IMPORTS: return createImports();
      case AvdlPackage.RPC_MESSAGE: return createRPCMessage();
      case AvdlPackage.NAME: return createName();
      case AvdlPackage.RETURN_TYPE: return createReturnType();
      case AvdlPackage.THROWS: return createThrows();
      case AvdlPackage.ARGUMENT: return createArgument();
      case AvdlPackage.ANNOTATION: return createAnnotation();
      case AvdlPackage.ALIAS_ANNOTATION: return createAliasAnnotation();
      case AvdlPackage.ORDER_ANNOTATION: return createOrderAnnotation();
      case AvdlPackage.NAMESPACE_ANNOTATION: return createNamespaceAnnotation();
      case AvdlPackage.JAVACLASS_ANNOTATION: return createJavaclassAnnotation();
      case AvdlPackage.DEF_TYPE: return createDefType();
      case AvdlPackage.BASE_TYPE_REF: return createBaseTypeRef();
      case AvdlPackage.COMPLEX_TYPE_REF: return createComplexTypeRef();
      case AvdlPackage.NUMBER_REF: return createNumberRef();
      case AvdlPackage.INT_REF: return createIntRef();
      case AvdlPackage.HEX_REF: return createHexRef();
      case AvdlPackage.DOUBLE_REF: return createDoubleRef();
      case AvdlPackage.BOOLEAN_REF: return createBooleanRef();
      case AvdlPackage.STRING_REF: return createStringRef();
      case AvdlPackage.IMPORT_TYPE_REF: return createImportTypeRef();
      case AvdlPackage.FIELD_TYPE: return createFieldType();
      case AvdlPackage.ARRAY_TYPE: return createArrayType();
      case AvdlPackage.MAP_TYPE: return createMapType();
      case AvdlPackage.UNION_TYPE: return createUnionType();
      case AvdlPackage.UNION_FIELD_TYPE: return createUnionFieldType();
      case AvdlPackage.CONST_VALUE: return createConstValue();
      default:
        throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object createFromString(EDataType eDataType, String initialValue)
  {
    switch (eDataType.getClassifierID())
    {
      case AvdlPackage.BOOL:
        return createBOOLFromString(eDataType, initialValue);
      case AvdlPackage.BASE_TYPE:
        return createBaseTypeFromString(eDataType, initialValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String convertToString(EDataType eDataType, Object instanceValue)
  {
    switch (eDataType.getClassifierID())
    {
      case AvdlPackage.BOOL:
        return convertBOOLToString(eDataType, instanceValue);
      case AvdlPackage.BASE_TYPE:
        return convertBaseTypeToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AvroIdl createAvroIdl()
  {
    AvroIdlImpl avroIdl = new AvroIdlImpl();
    return avroIdl;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Protocol createProtocol()
  {
    ProtocolImpl protocol = new ProtocolImpl();
    return protocol;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Definitions createDefinitions()
  {
    DefinitionsImpl definitions = new DefinitionsImpl();
    return definitions;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public de.thwildau.tm.moses.avro.avdl.Error createError()
  {
    ErrorImpl error = new ErrorImpl();
    return error;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Record createRecord()
  {
    RecordImpl record = new RecordImpl();
    return record;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Field createField()
  {
    FieldImpl field = new FieldImpl();
    return field;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public de.thwildau.tm.moses.avro.avdl.Enum createEnum()
  {
    EnumImpl enum_ = new EnumImpl();
    return enum_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EnumFields createEnumFields()
  {
    EnumFieldsImpl enumFields = new EnumFieldsImpl();
    return enumFields;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FixedLengthField createFixedLengthField()
  {
    FixedLengthFieldImpl fixedLengthField = new FixedLengthFieldImpl();
    return fixedLengthField;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Imports createImports()
  {
    ImportsImpl imports = new ImportsImpl();
    return imports;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RPCMessage createRPCMessage()
  {
    RPCMessageImpl rpcMessage = new RPCMessageImpl();
    return rpcMessage;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Name createName()
  {
    NameImpl name = new NameImpl();
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ReturnType createReturnType()
  {
    ReturnTypeImpl returnType = new ReturnTypeImpl();
    return returnType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Throws createThrows()
  {
    ThrowsImpl throws_ = new ThrowsImpl();
    return throws_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Argument createArgument()
  {
    ArgumentImpl argument = new ArgumentImpl();
    return argument;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Annotation createAnnotation()
  {
    AnnotationImpl annotation = new AnnotationImpl();
    return annotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AliasAnnotation createAliasAnnotation()
  {
    AliasAnnotationImpl aliasAnnotation = new AliasAnnotationImpl();
    return aliasAnnotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public OrderAnnotation createOrderAnnotation()
  {
    OrderAnnotationImpl orderAnnotation = new OrderAnnotationImpl();
    return orderAnnotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NamespaceAnnotation createNamespaceAnnotation()
  {
    NamespaceAnnotationImpl namespaceAnnotation = new NamespaceAnnotationImpl();
    return namespaceAnnotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public JavaclassAnnotation createJavaclassAnnotation()
  {
    JavaclassAnnotationImpl javaclassAnnotation = new JavaclassAnnotationImpl();
    return javaclassAnnotation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DefType createDefType()
  {
    DefTypeImpl defType = new DefTypeImpl();
    return defType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BaseTypeRef createBaseTypeRef()
  {
    BaseTypeRefImpl baseTypeRef = new BaseTypeRefImpl();
    return baseTypeRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ComplexTypeRef createComplexTypeRef()
  {
    ComplexTypeRefImpl complexTypeRef = new ComplexTypeRefImpl();
    return complexTypeRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NumberRef createNumberRef()
  {
    NumberRefImpl numberRef = new NumberRefImpl();
    return numberRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public IntRef createIntRef()
  {
    IntRefImpl intRef = new IntRefImpl();
    return intRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public HexRef createHexRef()
  {
    HexRefImpl hexRef = new HexRefImpl();
    return hexRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DoubleRef createDoubleRef()
  {
    DoubleRefImpl doubleRef = new DoubleRefImpl();
    return doubleRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BooleanRef createBooleanRef()
  {
    BooleanRefImpl booleanRef = new BooleanRefImpl();
    return booleanRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public StringRef createStringRef()
  {
    StringRefImpl stringRef = new StringRefImpl();
    return stringRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ImportTypeRef createImportTypeRef()
  {
    ImportTypeRefImpl importTypeRef = new ImportTypeRefImpl();
    return importTypeRef;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public FieldType createFieldType()
  {
    FieldTypeImpl fieldType = new FieldTypeImpl();
    return fieldType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ArrayType createArrayType()
  {
    ArrayTypeImpl arrayType = new ArrayTypeImpl();
    return arrayType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public MapType createMapType()
  {
    MapTypeImpl mapType = new MapTypeImpl();
    return mapType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public UnionType createUnionType()
  {
    UnionTypeImpl unionType = new UnionTypeImpl();
    return unionType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public UnionFieldType createUnionFieldType()
  {
    UnionFieldTypeImpl unionFieldType = new UnionFieldTypeImpl();
    return unionFieldType;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ConstValue createConstValue()
  {
    ConstValueImpl constValue = new ConstValueImpl();
    return constValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BOOL createBOOLFromString(EDataType eDataType, String initialValue)
  {
    BOOL result = BOOL.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertBOOLToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BaseType createBaseTypeFromString(EDataType eDataType, String initialValue)
  {
    BaseType result = BaseType.get(initialValue);
    if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String convertBaseTypeToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public AvdlPackage getAvdlPackage()
  {
    return (AvdlPackage)getEPackage();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @deprecated
   * @generated
   */
  @Deprecated
  public static AvdlPackage getPackage()
  {
    return AvdlPackage.eINSTANCE;
  }

} //AvdlFactoryImpl
